# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Maintainer: Filipe Laíns <lains@archlinux.org>
# Contributor: Marq Schneider <queueRAM@gmail.com>
# Contributor: Nick Østergaard
# Contributor: Rachel Mant <aur@dragonmux.network>
# Contributor: Kyle Keen <keenerd@gmail.com>

pkgname=kicad
pkgver=7.0.9
pkgrel=2
pkgdesc='Electronic schematic and printed circuit board (PCB) design tools'
arch=('loong64' 'x86_64')
url='http://kicad.org/'
license=('GPL')
depends=(
  'curl'
  'glew'
  'glm'
  'ngspice'
  'opencascade'
  'python'
  'python-wxpython'
  'wxwidgets-gtk3'
  'unixodbc'
)
makedepends=(
  'git'
  'cmake'
  'ninja'
  'mesa'
  'boost'
  'swig'
)
optdepends=(
  'kicad-library: for footprints, symbols and templates'
  'kicad-library-3d: for 3D models of components'
)
_commit='59f308850ed87dbe850669813dd9c23507d2b3c9'
source=(
  "$pkgname::git+https://gitlab.com/kicad/code/kicad.git#commit=$_commit"
  'fix-archive-permissions.patch'
  'fix-version-string.patch'
)
sha512sums=('SKIP'
            'e36912e4144c6debe33f1711ca7a2da020389a6e376282c70f534ce9e685d0b35b58d88b810327d8baeb3466e87eda246ebf181c18e134e80bc73b91dae4bf02'
            '17100967610c85ce2e8a860dcf703a87dc0c20f52d3f056cdb5d16323160e8594698bd51e095aea63c00a75ce8b121be681e93cec1bab72a8d1d4eb8065a91f5')
b2sums=()

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

prepare() {
  cd "$pkgname"

  patch -p1 -i "$srcdir/fix-archive-permissions.patch"
  patch -p1 -i "$srcdir/fix-version-string.patch"
}

build() {
  cmake \
    -B build \
    -S "$pkgname" \
    -G Ninja \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_INSTALL_PREFIX=/usr \
    -D KICAD_USE_EGL=ON \
    -D KICAD_BUILD_I18N=ON \
    -D KICAD_I18N_UNIX_STRICT_PATH=ON \
    -D KICAD_BUILD_QA_TESTS=OFF \
    -W no-dev

  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build

  strip "$STRIP_SHARED" "${pkgdir}"/usr/lib/python*/site-packages/_pcbnew.so
}

# vim:set ts=2 sw=2 et:
